package com.ln.lnzw.app;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDexApplication;

import com.blankj.utilcode.util.Utils;
import com.bumptech.glide.request.target.ViewTarget;
import com.ln.lnzw.R;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator;
import com.scwang.smartrefresh.layout.api.RefreshFooter;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wuwei on 2018/3/21.
 */

public class AppApplication extends MultiDexApplication {
    public static AppApplication mAppApplication;
    static {
        //设置全局的Header构建器
        SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
            @Override
            public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
                ClassicsHeader classicsHeader = new ClassicsHeader(context);
                classicsHeader.setTextSizeTitle(15);//设置标题文字大小（sp单位）
                classicsHeader.setDrawableSize(15);//同时设置箭头和图片的大小（dp单位）
                layout.setPrimaryColorsId(R.color.page_bg, R.color.tab_unselect);//全局设置主题颜色
                return classicsHeader;//.setTimeFormat(new DynamicTimeFormat("更新于 %s"));//指定为经典Header，默认是 贝塞尔雷达Header
            }
        });
        //设置全局的Footer构建器
        SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
            @Override
            public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
                //指定为经典Footer，默认是 BallPulseFooter
                ClassicsFooter classicsFooter = new ClassicsFooter(context);
                classicsFooter.setTextSizeTitle(15);//设置标题文字大小（sp单位）
                classicsFooter.setDrawableSize(15);//同时设置箭头和图片的大小（dp单位）
                layout.setPrimaryColorsId(R.color.page_bg, R.color.tab_unselect);//全局设置主题颜色
                return classicsFooter;
            }
        });
    }
    @Override
    public void onCreate() {
        super.onCreate();
        mAppApplication = this;
//        ViewTarget.setTagId(R.id.glide_tag);
        Utils.init(mAppApplication);
        ViewTarget.setTagId(R.id.glide_tag);
    }

    /** 获取Application */
    public static AppApplication getApp() {
        return mAppApplication;
    }

    public static void set(AppApplication app) {
        mAppApplication = app;
    }
}
